Skip to content

fix(git): recover interrupted initial sync#80

Merged
yyzxw merged 1 commit into
BaizeAI:mainfrom
usernameisnull:fix/git-initial-sync-recovery
Jul 17, 2026
Merged

fix(git): recover interrupted initial sync#80
yyzxw merged 1 commit into
BaizeAI:mainfrom
usernameisnull:fix/git-initial-sync-recovery

Conversation

@usernameisnull

Copy link
Copy Markdown
Contributor

Handle unborn repositories and clean up stale HEAD locks before the initial pull.
Add local end-to-end coverage for both recovery paths.

Fixes errors seen during sync:

  • You do not have the initial commit yet
  • error: pathspec 'HEAD' did not match any file(s) known to git
  • cannot lock ref 'HEAD': reference already exists

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces logic to safely handle Git synchronization in unborn repositories and clean up stale .git/HEAD.lock files left by interrupted operations. It adds helper methods hasInitialCommit and removeStaleHEADLock to GitLoader, skips stash and reset operations when no initial commit exists, and adds corresponding unit tests. Feedback on the changes includes a critical test assertion bug in datasource_git_test.go where an index mismatch (bbs[7] instead of bbs[8]) will cause test failures, and a potential TOCTOU race condition in removeStaleHEADLock where os.Remove could fail if the lock file is deleted by another process between the Lstat check and the deletion.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread internal/pkg/datasources/datasource_git_test.go Outdated
Comment thread internal/pkg/datasources/datasource_git.go
@usernameisnull
usernameisnull force-pushed the fix/git-initial-sync-recovery branch 2 times, most recently from 2cc0388 to 6de66e2 Compare July 17, 2026 08:08
@usernameisnull
usernameisnull force-pushed the fix/git-initial-sync-recovery branch from 6de66e2 to 804ca70 Compare July 17, 2026 08:18
@yyzxw
yyzxw merged commit d749de1 into BaizeAI:main Jul 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants